﻿using MyCode.Project.Domain.Message.Request.User;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Infrastructure.Extensions;
using MyCode.Project.Services;
using System.Web.Http;

namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
{
    /// <summary>
    ///店长宝典  相关
    /// </summary>
    public class BaoDianController : BaseWechatController
    {
        private IBaoDianService _baoDianService;
        private IBillKeepingService _billKeepingService;

        /// <summary>
        /// 初始化一个<see cref="ClerkController"/>类型的实例
        /// </summary>
        public BaoDianController(IBaoDianService baoDianService, IBillKeepingService billKeepingService)
        {
            _baoDianService = baoDianService;
            _billKeepingService = billKeepingService;   
        }

        #region GetMemberInfo 老客邀约计划的获取会员列表
        /// <summary>
        /// 老客邀约计划的获取会员列表
        /// </summary>
        /// <param name="request">搜索条件</param>
        /// <returns></returns>
        [HttpPost]
        public PageResult<MemberCusResp> GetMemberInfo(PagedSearch<MemberRequst> request)
        {
            if (!request.Condition.ShopID.HasValue)
            {
                throw new BaseException("请选择一个门店");
            }
            var shopIds = _billKeepingService.GetShopAssetRules(this.CurrentLogin.CustomerId, request.Condition.ShopID.SafeValue());
            return _baoDianService.GetMemberInfo(request, this.CurrentLogin, shopIds);
        }

        #endregion


    }
}
